(function() {
    $('form').validate({
        rules: {
            in_balance: 'required'
        },
        messages: {
            in_balance: '请输入入金金额'
        },
        submitHandler: function(form) {
            var params = {
                in_balance: form.in_balance.value
            }

            $.ajax({
                url: 'index.php?s=/index/user/inBalance',
                type: 'post',
                dataType: 'json',
                data: params,
                success: function(res) {
                    if (res.code == 0) {
                        layer.msg('入金成功');
                        location.reload();
                    } else {
                        layer.msg(res.msg);
                    }
                },
                error: function() {
                    layer.msg('连接服务器失败');
                }
            });
        }
    });
})();